﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="paypage.aspx.cs" Inherits="MxWeiXinPF.Web.api.payment.paypage" %>

<!DOCTYPE html>
<html>
<head id="Head1" runat="server">
    <title>微支付</title>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8">
    <meta content="application/xhtml+xml;charset=UTF-8" http-equiv="Content-Type">
    <meta content="telephone=no, address=no" name="format-detection">
    <meta content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"
        name="viewport">
    <script type="text/javascript" src="http://res.mail.qq.com/mmr/static/lib/js/jquery.js"></script>
    <script type="text/javascript" src="http://res.mail.qq.com/mmr/static/lib/js/lazyloadv3.js"></script>
    <script type="text/javascript" src="../../../scripts/jquery/jquery.query.js"></script>
    <script type="text/javascript" charset="UTF-8" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
    <script type="text/javascript">

        //调用微信JS api 支付
        function jsApiCall()
        {
            WeixinJSBridge.invoke(
            'getBrandWCPayRequest',
            <%=wxJsApiParam%>,//josn串
                    function (res)
                    {                 
                       // WeixinJSBridge.log(res.err_msg);
                        //alert(res.err_code + res.err_desc + res.err_msg);
                        var rpage=$.query.get("rpage");
                        var openid = $.query.get("openid");
                        var otid = $.query.get("orderid");
                        var wid=$.query.get("wid");
                        var shopid=$.query.get("shopid");
                        var radNum = Math.random();
                        if (res.err_msg == 'get_brand_wcpay_request:ok') {
                            //去判断交易信息
                            window.location.href = "/api/payment/wxpay/payResult.aspx?wid="+wid+"&otid="+otid+"&openid="+openid+"&shopid="+ shopid+"&radnum="+radNum+"&rpage="+escape(rpage);
                            return true;
                        } else {

                            //alert('支付失败：'+res.err_msg);                        
                            window.location.href = rpage; 
                            return false;
                        }
                    }
                    );
     }

               function callpay()
               {
                   if (typeof(WeixinJSBridge) == "undefined")
                   {
                       if (document.addEventListener)
                       {
                           document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
                       }
                       else if (document.attachEvent)
                       {
                           document.attachEvent('WeixinJSBridgeReady', jsApiCall);
                           document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
                       }
                   }
                   else
                   {
                       jsApiCall();
                   }
               }
               
    </script>
    <style type="text/css">
        *
        {
            margin: 0px;
            padding: 0px;
            -webkit-box-sizing: border-box;
        }
        
        .body
        {
            text-align: center;
            width: 100%;
            padding: 60px 20px;
        }
        
        .body .ordernum
        {
            font-size: 14px;
            line-height: 30px;
        }
        
        .body .money
        {
            font-size: 20px;
            font-weight: bold;
            line-height: 60px;
        }
        
        .body .time
        {
            font-size: 16px;
            font-weight: bold;
            line-height: 30px;
        }
        
        .body .btn
        {
            display: block;
            background: #25a52e;
            text-decoration: none;
            border-radius: 2px;
            color: #fff;
            height: 44px;
            line-height: 44px;
            font-size: 18px;
            margin-top: 20px;
        }
    </style>
</head>
<body>
    <form id="Form1" runat="server">
    <br />
    <section class="body">
        <div class="ordernum">
            订单号：<asp:Literal ID="litout_trade_no" runat="server" EnableViewState="false"></asp:Literal></div>
        <div class="money">
            共计金额￥<asp:Literal ID="litMoney" runat="server" EnableViewState="false"></asp:Literal></div>
        <div class="time">
            下单时间：<asp:Literal ID="litDate" runat="server" EnableViewState="false"></asp:Literal></div>
        <div class="paytype">
            支付方式：<asp:Literal ID="litPayType" runat="server" EnableViewState="false"></asp:Literal></div>
        <%-- <a href="javascript:void(0);" class="btn" id="getBrandWCPayRequest">确认支付</a>--%>
    </section>
    <br />
    <div align="center">
        <asp:Button ID="submit" runat="server" Text="立即支付"  OnClientClick="javascript:callpay();return false;" Style="width: 210px;
            height: 50px; border-radius: 15px; background-color: #00CD00; border: 0px #FE6714 solid;
            cursor: pointer; color: white; font-size: 16px;" />
    </div>
    <%-- <div align="center">
        <br />
        <br />
        <br />
        <asp:Button ID="submit" runat="server" Text="立即支付" OnClientClick="callpay()" Style="width: 210px;
            height: 50px; border-radius: 15px; background-color: #00CD00; border: 0px #FE6714 solid;
            cursor: pointer; color: white; font-size: 16px;" />
    </div>--%>
    </form>
</body>
</html>
